﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Microsoft.Win32;
using System.Collections;
using System.IO;
using System.Reflection;
using Srvtools;

namespace EEPClientDBSocket
{
    public partial class frmProviderName : Form
    {
        public frmProviderName()
        {
            InitializeComponent();
        }

        String SolutionName;
        public frmProviderName(String Solution)
        {
            SolutionName = Solution;
            InitializeComponent();
        }

        private void frmProviderName_Load(object sender, EventArgs e)
        {
            object[] param = new object[1];
            param[0] = SolutionName;
            object[] myRet = CliUtils.CallMethod("GLModule", "GetProviderName", param);
            if (myRet[1] != null && myRet[1] is ArrayList)
            {
                for (int i = 0; i < (myRet[1] as ArrayList).Count;i++ )
                    this.lbDataModule.Items.Add((myRet[1] as ArrayList)[i].ToString());
            }
        }

        private void lbDataModule_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.lbDBCommand.Items.Clear();
            String ModuleName = this.lbDataModule.SelectedItem.ToString() + ".dll";
            int iPos = ModuleName.ToUpper().IndexOf(".DLL");

            object[] param = new object[3];
            param[0] = SolutionName;
            param[1] = ModuleName;
            param[2] = iPos;
            object[] myRet = CliUtils.CallMethod("GLModule", "GetDataModule", param);
            if (myRet[1] != null && myRet[1] is ArrayList)
            {
                for (int i = 0; i < (myRet[1] as ArrayList).Count; i++)
                    this.lbDBCommand.Items.Add((myRet[1] as ArrayList)[i].ToString());
            }
        }

        public String Module;
        public String DBCommand;
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.lbDataModule.SelectedIndex != -1)
                Module = this.lbDataModule.SelectedItem.ToString();
            if (this.lbDBCommand.SelectedIndex != -1)
                DBCommand = this.lbDBCommand.SelectedItem.ToString();
        }
    }
}